/*
 *         Copyright (c) KUBOTA Corporation and HUDSON SOFT,
 *                  1994, 1995 All Rights Reserved
 *
 *  This software comprises unpublished confidential information of
 *  KUBOTA Corp. and HUDSON SOFT. It may not be used, copied or made 
 *  available to anyone, except in accordance with the license under
 *  which it is furnished.
 */
static char SccsId[] = "@(#)acrotxsc.c	1.5	9/19/95";
#include <farl.h>
#include <agl.h>

/*
 * 与えられたsin, cosでカメラＸ軸回転
 */
void
AGLRotateCameraXSC(fix1015 SinXX, fix1015 CosXX)
{
     fix187		sinx187, cosx187;

     if (SinXX == 0 && CosXX == 0x7fff) return;

     /*
      * fix1015のsin, cosしか与えられないので、fix187に変換する。
      */
     sinx187 = CONV1015TO187(SinXX);
     cosx187 = CONV1015TO187(CosXX);

     /*
      * カメラはマトリクスの逆回転で実現しているため、
      * sin(-angle), cos(-angle) を求める必要がある。
      * 	sin(-angle) = -sin(angle)
      * 	cos(-angle) =  cos(angle)
      */

     /* camMatrix187を回転させる */
     if (__AGLCamera.camChanged == -2) {
	  FarlGetRotateXSC4x4M187(~sinx187+1, cosx187,
	  		(unsigned short*)__AGLCamera.camMatrix187);
     } else {
	  FarlSetSrcMatrix((unsigned short*)__AGLCamera.camMatrix187);
	 FarlRotateXSC4x4M187(~sinx187 + 1, cosx187);
	 FarlCopyDstToMem4x4((unsigned short*)__AGLCamera.camMatrix187);
     }

     /* camMatrix1015を回転させる */
     if (__AGLCamera.camChanged < 0) {
	  FarlGetRotateXSC3x3M1015(~SinXX + 1, CosXX,
	  		(unsigned short*)__AGLCamera.camMatrix1015);
     } else {
	  FarlSetSrcMatrix3x3((unsigned short*)__AGLCamera.camMatrix1015);
	 FarlRotateXSC3x3M1015(~SinXX + 1, CosXX);
	 FarlCopyDstToMem3x3((unsigned short*)__AGLCamera.camMatrix1015);
     }
     __AGLCamera.camChanged = 1;
}
